<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="msg">
        <a href="../php/sign.js">请登录</a>
    </div>
    <table>

    </table>
    <script src="../php/cookie.js"></script>
    <script>
        var msg = document.querySelector('.msg');
        var table = document.querySelector("table");
        if (getCookie("lgc")) {
            var cookie = getCookie("lgc");
            msg.innerHTML = `
                <span>欢迎您，用户${cookie}</span>
                <button class="btnOut">退出</button>
            `
            var xhr = new XMLHttpRequest();
            xhr.open("get", "../php/sy.php", true);
            xhr.send();
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var str = JSON.parse(xhr.responseText);
                    if (str.status == true) {
                        var list = str.list;
                        console.log(list);
                        table.innerHTML = `
            <thead>
            <tr>
               
                <th>编号</th>
                <th>姓名</th>
                <th>班级</th>
                <th>语文</th>
                <th>数学</th>
                <th>英语</th>
                <th>总分</th>
                <th>编辑</th>
                <th>删除</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th> </th>
                <th>${list}</th>
                <th>班级</th>
                <th>语文</th>
                <th>数学</th>
                <th>英语</th>
                <th>总分</th>
                <th>编辑</th>
                <th>删除</th>
            </tr>
        </tbody>
            `
                    }

                }
            }

        }
    </script>
</body>

</html>